GBML manual / Drawing

draw_sprite_scaled

Like draw_sprite, with rotation, scale, flips and an explicit depth (quantised the same way the depth instance variable is).

Works differently on Game Boy - A turned, resized or leaned sprite shows the nearest look the build draws ahead of time: turns in steps (Project Settings: Sprite turn steps), a few sizes and leans, and a negative size mirrors exactly. The looks share the 384 tiles of video memory, so there is room for few.

Works differently on Game Boy Color - The Game Boy Color cannot turn, resize or lean a sprite, so the build draws those looks ahead of time and shows the nearest one: turns come in steps (Project Settings: Sprite turn steps), sizes and leans in a few steps. Each look takes memory.

Works differently on Sega Genesis - The Sega Genesis can turn a picture over (a size of 1 or -1), but it cannot stretch or shrink one. Make the sizes you need as frames of an animation instead.

On other consoles this differs: see Side by side and How the consoles differ.

Syntax

draw_sprite_scaled(spr, x, y, frame, angle, xscale, yscale, flip_x, flip_y, depth)

Arguments

NameType
sprsprite
xreal
yreal
frameint
anglereal
xscalereal
yscalereal
flip_xbool
flip_ybool
depthreal

Returns

Nothing.

Description

Everything draw_sprite does, plus its own rotation, scale, flips and depth - independent of this instance's own angle/xscale/yscale/flip_x/flip_y/depth, which is the entire reason to reach for this scaled form: a spinning collectible glow above a character that stands still, or a shadow that never rotates even while the sprite above it spins. depth here is quantised into the same bands the depth instance variable is - it is not a finer-grained z-order than that field gets.

x and y are a place in the room, counted from the room's top-left corner, exactly as in draw_sprite.

A negative xscale/yscale mirrors, the same as the xscale/yscale instance fields - combined with flip_x/flip_y by XOR, so passing both a mirrored scale and the matching flip cancels back to unmirrored rather than doubling up.

Example

draw_sprite_scaled(spr_doc_glow, x, y - 12, 0, angle + 45, 1, 1, false, false, depth - 1);

The glow spins 45 degrees ahead of whichever way this instance itself is facing, at normal scale, not flipped, drawn one depth band in front of the instance's own sprite.

A real capture - the glow icon rotated 45 degrees, reading as an upright square rather than the plain diamond draw_sprite's own capture showsA real capture - the glow icon rotated 45 degrees, reading as an upright square rather than the plain diamond draw_sprite's own capture shows
A real capture - the glow icon rotated 45 degrees, reading as an upright square rather than the plain diamond draw_sprite's own capture shows

On the GBA

A negative xscale/yscale mirrors, combined with flip_x/flip_y by XOR (both true at once cancels back to unmirrored) - the same rule the xscale/yscale instance fields follow. A pure mirror (magnitude exactly 1) costs nothing beyond what flip_x/flip_y alone already cost - no affine matrix; any other magnitude, or a non-zero angle, claims one of the hardware’s 32.

See also: draw_sprite